<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            line-height: 200px;
            text-align: center;
            background-color: #aaa;
            margin: 0 auto;
        }
        #but{
            display: block;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div class="box">点名</div>
    <input type="button" id="but" value="开始"> 

    <script>

        var arr=[
            "同学1","同学2","同学3","同学4","同学5","同学6","同学7","同学8","同学8","同学10",
        ];

        var oBox = document.querySelector('.box');
        var oBut = document.querySelector('#but');

        var t=null;
        oBut.onclick= function(){
            if(this.value ==='开始'){
                function fn(){
                    var index =parseInt(Math.random()*arr.length);
                    oBox.innerHTML=arr[index];
                }
                
                // fn();
                t=setInterval(fn,1);
                this.value='停止';
                
            }else{
                clearInterval(t);
                this.value='开始';
            }
        }





        oBut.onclick= function(){
            if(this.value ==='开始'){

            }
            else {

            }
        }




        var res = '';
        arr.forEach(function(){
           res += ``
        })

        oUl.innerHTML = res ;






    </script>
</body>
</html>